home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / surfsrc3.zip / LITEMENU.INC < prev    next >
Text File  |  1991-09-28  |  6KB  |  138 lines

  1. procedure LITEMENU;
  2. { Menu to change lighting parameters }
  3.  
  4. var Cmmd: integer;         { user's inputted choice }
  5.     Lite: integer;         { light source # }
  6.     Mat: integer;          { material # }
  7.     Eps: real;             { temp for Epsilon }
  8.     Rsh: real;             { temp for Randshade }
  9.     ch: char;
  10.  
  11. begin
  12.   repeat
  13.     openwin (13,6,67,21, TRUE);
  14.     gotoXY (20,1);
  15.     writeln ('LIGHTING MENU');
  16.     writeln; writeln;
  17.     writeln ('1  Material Parameters (', Nmatl,')');
  18.     writeln ('2  Light Sources (', Nlite,')');
  19.     write   ('3  Gouraud Interpolation (');
  20.     if (Interpolate) then
  21.       writeln ('On)')
  22.     else
  23.       writeln ('Off)');
  24.     write   ('4  Shadowing (');
  25.     if (Shadowing) then
  26.       writeln ('On)')
  27.     else
  28.       writeln ('Off)');
  29.     writeln ('0  Return to Parameters Menu');
  30.     writeln;
  31.     write ('Command: ');
  32.     Cmmd := getkey;
  33.     if ((Cmmd < 1) or (Cmmd > 4)) and (Cmmd <> 0) then
  34.       write(^G)
  35.     else begin
  36.       writeln (Cmmd);
  37.       case Cmmd of
  38.         1: begin
  39.           if Nmatl < 1 then begin
  40.             writeln('No Materials Defined!');
  41.             write ('Press any key...');
  42.             ch := readkey;
  43.           end else begin
  44.             Mat := 1;
  45.             Mat := getoneint (Mat, 1, Nmatl, 'Material Number');
  46.             writeln ('Shading is computing from a formula like:');
  47.             writeln ('  E = I[R1(cos s)**R2 + R3cos n] + Ambient');
  48.             R1[Mat] := getonereal (R1[Mat], 0.0, 99999.0, 'R1');
  49.             R2[Mat] := getonereal (R2[Mat], -99999.0, 99999.0, 'R2');
  50.             R3[Mat] := getonereal (R3[Mat], 0.0, 99999.0, 'R3');
  51.             Ambient[Mat] := getonereal (Ambient[Mat], 0.0, 1.0,
  52.                 'Ambient Light');
  53.             Color[Mat] := getoneint (Color[Mat], 0, Ncolors, 
  54.                 'Color (or 0 to enter RGB)');
  55.             if (Color[Mat] = 0) then begin
  56.               Color[Mat] := 2;  { for wireframe plotting }
  57.               Redmax[Mat] := getoneint (Redmax[Mat], 1, 256, 'Max Red  ');
  58.               Grnmax[Mat] := getoneint (Grnmax[Mat], 1, 256, 'Max Green');
  59.               Blumax[Mat] := getoneint (Blumax[Mat], 1, 256, 'Max Blue ');
  60.             end else
  61.               color_to_rgb (Color[Mat], Redmax[Mat], Grnmax[Mat], Blumax[Mat]);
  62.           end;  { if Nmatl < 1 }
  63.         end; { 1: }
  64.         2: begin
  65.           if (Nlite > 1) then
  66.             writeln ('There are currently ', Nlite, ' light sources.')
  67.           else
  68.             writeln ('There is currently ', Nlite, ' light source.');
  69.           writeln ('Entering a light source number of 0 deletes the last');
  70.           writeln ('  light source.  Entering a light source number of ',
  71.                   Nlite+1);
  72.           writeln ('  will add a new light source.');
  73.           Lite := 1;
  74.           Lite := getoneint (Lite, 0, Nlite+1, 'Light Source Number');
  75.           if (Lite = 0) then begin
  76.             if (Nlite < 2) then begin
  77.               writeln ('Error: Cant delete all light sources!');
  78.               write ('Press any key...');
  79.               ch := readkey;
  80.             end else
  81.               Nlite := Nlite - 1;
  82.           end;
  83.           if (Lite > Nlite) then begin
  84.             Nlite := Nlite + 1;
  85.             Lite := Nlite;
  86.             Xlite[Lite] := 0.0;
  87.             Ylite[Lite] := 0.0;
  88.             Zlite[Lite] := 0.0;
  89.             Intensity[Lite] := 1.0;
  90.           end;
  91.           if (Lite > 0) then begin
  92.             Xlite[Lite] := getonereal (Xlite[Lite], -99999.0, 99999.0, 'X');
  93.             Ylite[Lite] := getonereal (Ylite[Lite], -99999.0, 99999.0, 'Y');
  94.             Zlite[Lite] := getonereal (Zlite[Lite], -99999.0, 99999.0, 'Z');
  95.             Intensity[Lite] := getonereal (Intensity[Lite], 0.0, 2.0,
  96.                                'Intensity');
  97.           end; { if Lite }
  98.         end; { 2: }
  99.         3: begin
  100.           writeln ('Epsilon: Largest Change in Shading to Interpolate');
  101.           writeln ('  A value of about 0.3 usually works well.');
  102.           writeln ('  Enter a value of 0.0 for no interpolation.');
  103.           Eps := Epsilon;
  104.           Eps := getonereal (Eps, 0.0, 1.0, 'Epsilon');
  105.           if (Eps > 0.0) then begin
  106.             Interpolate := TRUE;
  107.             Epsilon := Eps;
  108.           end else
  109.             Interpolate := FALSE;
  110.           if (Interpolate) then begin
  111.             writeln ('Entering a random shading value greater than 0');
  112.             writeln ('  will cause the shading at all pixels in a Gouraud');
  113.             writeln ('  interpolated rendering to be increased by a random');
  114.             writeln ('  value in the range of 0 to the Random Shade.');
  115.             writeln ('(Recommended values are no greater than the size of');
  116.             writeln ('  one distinguishable shade -- for instance, on a 16');
  117.             writeln ('  shade system, use numbers no greater than ',
  118.                      (1.0/16.0):7:3,')');
  119.             Rsh := Randshade;
  120.             Rsh := getonereal (Rsh, 0.0, 1.0, 'Random Shade');
  121.             if (Rsh > 0.0) then begin
  122.               Dorandom := TRUE;
  123.               Randshade := Rsh;
  124.             end else
  125.               Dorandom := FALSE;
  126.           end; { if Interpolate }
  127.         end; { 3: }
  128.         4: begin
  129.           if (Shadowing) then
  130.             Shadowing := FALSE
  131.           else
  132.             Shadowing := TRUE;
  133.         end; { 4: }
  134.       end; { case Cmmd }
  135.     end;
  136.   until (Cmmd = 0)
  137. end; { procedure Litemenu }
  138.